 --@auth 胡荣桓
 --@time 2016-10-24
 -- 当有主叫追踪并且没有主叫回拨时执行
toext = false
digit = nil

if argv[4] == "1" then
	freeswitch.consoleLog("INFO","直拨总机".."\n")
	toext = true
end
session:setAutoHangup(false)
freeswitch.consoleLog("INFO","cid_tracer ivr".."\n")
function onInput(s,type,obj,arg) 
	digit = obj.digit
	if(obj.digit == "*" ) then
		if not toext then
			s:setVariable('cid_tracer','true')
			s:execute('ivr',argv[2])
		end
		return 'break'
	end
	return ''
end

session:answer();

lan = session:getVariable("language")
session:setInputCallback('onInput','')
session:sayPhrase("yunpbx_greet_long",argv[1],lan)
if digit == nil then
	digit = session:getDigits(1, "", 5000);
end
freeswitch.consoleLog("INFO","get digit is "..digit.."\n")
if digit == "*" then
	if not toext then
		session:setVariable('cid_tracer','true')
		session:execute('ivr',argv[2])
	end
else
	session:execute('transfer',argv[3]..' XML opbx')
end


